package mroute

import (
	"github.com/gin-gonic/gin"
	"mygo/mystruct"
	"mygo/mymongo"
	"mygo/mauth"
)

// 获取用户对于表的权限
func MyAuth(cont *gin.Context) {
	Muserboot := mauth.Get_token(cont)
	if Muserboot == nil {
		Muserboot = &mystruct.Muser{
			Name: "游客",
			Account: "",
			Standing: mystruct.AUTH_Tourist,
		}
	}
	_, Body := mymongo.Auth_api_edit("", Muserboot, &mystruct.Retdate{}, cont.Query("code"))
	if Body == nil {
		cont.JSON(mystruct.StatusUnauthorized, gin.H{"error": "表不存在"})
		cont.Abort()
		return 
	}
	bot_type := mauth.Get_auth(Muserboot, Body)
	cont.JSON(mystruct.StatusOK, gin.H{"code": mystruct.MyCodeOk, "msg": bot_type})
}
